/**
 * MidState.java
 *
 * Provider: CoderDream's Studio
 *
 * History
 *	Date(DD/MM/YYYY)    Author          Description
 * ----------------------------------------------------------------------------
 *	Oct 29, 2007			XuLin	Created
 */
package com.coderdream.chapter19.state.a3;

/**
 * @author XL
 * 
 */
public class MidState implements State {

	private static MidState singleton = new MidState();

	/**
	 * 构造函数为private
	 */
	private MidState() {
	}

	/**
	 * 取得唯一的对象实例
	 * 
	 * @return
	 */
	public static State getInstance() {
		return singleton;
	}

	/**
	 * 设定时间
	 * 
	 */
	public void doClock(Context context, int hour) {
		if (hour < 9 || 17 <= hour) {
			context.changeState(NightState.getInstance());
		} else if ((hour < 12 && 9 <= hour) || (hour < 17 && 13 <= hour)) {
			context.changeState(DayState.getInstance());
		}
	}

	/**
	 * 使用金库
	 */
	public void doUse(Context context) {
		context.recordLog("异常：午餐时间使用金库！");

	}

	/**
	 * 警铃
	 */
	public void doAlarm(Context context) {
		context.callSecurityCenter("警铃（午餐时间）");
	}

	/**
	 * 一般通话
	 */
	public void doPhone(Context context) {
		context.callSecurityCenter("午餐时间的通话录音");
	}

	/**
	 * 输出字符串
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "[午餐时间]";
	}

}
